$(function () {
   $('#keyword1').on('keyup',function (){
      var keyword1 = $(this).val();
      console.log(keyword1);
      $.ajax({
         type        :'GET',
         url         :'http://localhost:8080/MyJpetStore/userNameSearchServlet?keyword1='+keyword1,
         success     :function (data) {
            console.log(data);
            if (data.trim() === "Username Exist!") {
               $('#usernameAvailability').text('用户名已存在').css('color', 'red');
            } else {
               $('#usernameAvailability').text('用户名可用').css('color', 'green');
            }
         },
         error       :function (errorMsg){
            console.log(errorMsg);
         }
      });
   });
});